#pragma once
#include "UltimatePhysXPrecompiled.h"
#include "UltimatePhysXSubsystem.h"


UltimatePhysXSubsystem::UltimatePhysXSubsystem(void)
{
}


UltimatePhysXSubsystem::~UltimatePhysXSubsystem(void)
{
}

bool UltimatePhysXSubsystem::initPhysics()
{
	
		mPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION);
		if (!mPhysicsSDK)  return false;

		mPhysicsSDK->getFoundationSDK().getRemoteDebugger()->connect("localhost", 5425);

		mPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.01);
		
 	

}

UltimatePhysicsScene * UltimatePhysXSubsystem::createPhysicsScene()
{
		NxSceneDesc  mNxSceneDesc;
		mNxSceneDesc.simType = NX_SIMULATION_HW;
		//mNxSceneDesc.gravity = NxVec3(0,-90.8f,0);
		mNxSceneDesc.gravity = NxVec3(0,0,0);
		//sceneDesc.groundPlane = true;

		mPhysXScene = new UltimatePhysXScene(mPhysicsSDK,&mNxSceneDesc);

		if(!mPhysXScene->initScene())
			return 0;	//TODO throw exception
		
	
		return  mPhysXScene;
}

void  UltimatePhysXSubsystem::destroyPhysicsScene()
{
	delete mPhysXScene;
}

